#
# Install needed packages
#
- name: Install needed nfs server packages
  package: name={{ item }} state=present
  with_items:
  - nfs-utils
  - rpcbind
  tags:
  - nfs/server

- name: setup /etc/exports
  copy: src={{ inventory_hostname }}-exports dest=/etc/exports
  register: exports
  tags:
  - nfs/server

- name: enable nfs-related services and run them (fedora)
  service: name={{ item }}  enabled=true state=started
  with_items:
  - rpc-statd
  when: ansible_distribution == 'Fedora'
  tags:
  - nfs/server

- name: enable nfs-related services and run them (rhel)
  service: name={{ item }}  enabled=true state=started
  with_items:
  - rpcbind
  - nfs-server
  - nfs-lock
  when: ansible_distribution == 'RedHat'
  tags:
  - nfs/server

- name: Kick exportfs if /etc/exports changed
  command: /usr/sbin/exportfs -ra
  when: exports.changed
  tags:
  - nfs/server

